package com.example.academic_affairs_system.controller;

import com.example.academic_affairs_system.common.R;
import com.example.academic_affairs_system.model.dto.user.HandlerStudentDTO;
import com.example.academic_affairs_system.model.dto.user.LoginDTO;
import com.example.academic_affairs_system.model.dto.user.RegisterDTO;
import com.example.academic_affairs_system.model.dto.user.RestPasswordDTO;
import com.example.academic_affairs_system.service.IAasUserService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import javax.validation.Valid;

/**
 * 教务系统用户表 前端控制器
 *
 * @author hjx
 * @since 2023-01-31
 */
@RestController
@RequestMapping("/sys/user")
public class AasUserController {
  @Resource IAasUserService iAasUserService;

  @PostMapping("/register")
  public R register(@RequestBody RegisterDTO dto) {
    return R.ok(iAasUserService.register(dto));
  }



  @PostMapping("/add")
  public R add(@RequestBody @Valid HandlerStudentDTO dto) {
    return R.ok(iAasUserService.addStudent(dto));
  }

  @PostMapping("/edit")
  public R edit(@RequestBody @Valid HandlerStudentDTO dto) {
    return R.ok(iAasUserService.edit(dto));
  }

  @GetMapping("/delete/{studentId}")
  public R delete(@PathVariable("studentId") long studentId) {
    return R.ok(iAasUserService.delete(studentId));
  }
}
